import QtQuick 2.0
import QtQuick.Controls 2.14

import "../../../commonUI"
import "../../../basic"

// 快捷键
Item {
    id: customShotCutRoot
    anchors.left: parent.left
    anchors.right: parent.right
    height: 800

    Label {
        id: shotcutTitleLabel
        text: qsTr("快捷键")
        font.pixelSize: 22
        font.bold: true
        font.family: BasicConfig.heiTiFont
        anchors.left: parent.left
        color: "white"
    }
    Label {
        id: functionLabel
        text: qsTr("功能说明")
        font.pixelSize: 20
        font.bold: true
        font.family: BasicConfig.heiTiFont
        anchors.bottom: shotcutTitleLabel.bottom
        anchors.left: shotcutTitleLabel.right
        anchors.leftMargin: 128
        color: "white"
    }
    Label {
        id: shotcutTitle
        text: qsTr("快捷键")
        font.pixelSize: 20
        font.bold: true
        font.family: BasicConfig.heiTiFont
        anchors.bottom: shotcutTitleLabel.bottom
        anchors.left: functionLabel.right
        anchors.leftMargin: 80
        color: "white"
    }
    Label {
        id: globalShotCutLabel
        text: qsTr("全局快捷键")
        font.pixelSize: 20
        font.bold: true
        font.family: BasicConfig.heiTiFont
        anchors.bottom: shotcutTitleLabel.bottom
        anchors.left: shotcutTitle.right
        anchors.leftMargin: 220
        color: "white"
    }
    ListModel {
        id: shotCutModel
        ListElement { description: "播放/暂停"; shotcut: "Ctrl + P"; globalShotcut: "Ctrl + Alt + P" }
        ListElement { description: "上一首"; shotcut: "Ctrl + Left"; globalShotcut: "Ctrl + Alt + Left" }
        ListElement { description: "下一首"; shotcut: "Ctrl + Right"; globalShotcut: "Ctrl + Alt + Right" }
        ListElement { description: "音量加"; shotcut: "Ctrl + Up"; globalShotcut: "Ctrl + Alt + Up" }
        ListElement { description: "音量减"; shotcut: "Ctrl + Down"; globalShotcut: "Ctrl + Alt + Down" }
        ListElement { description: "mini/完整模式"; shotcut: "Ctrl + M"; globalShotcut: "Ctrl + Alt + M" }
        ListElement { description: "喜欢歌曲"; shotcut: "Ctrl + L"; globalShotcut: "Ctrl + Alt + L" }
        ListElement { description: "打开/关闭歌词"; shotcut: "Ctrl + D"; globalShotcut: "Ctrl + Alt + D" }
    }

    Column {
        id: col1
        anchors.top: shotcutTitleLabel.bottom
        anchors.left: shotcutTitleLabel.right
        anchors.right: parent.right
        anchors.leftMargin: 128
        anchors.topMargin: 30
        spacing: 30
        Repeater {
            model: shotCutModel
            Item {
                anchors.left: parent.left
                anchors.right: parent.right
                anchors.rightMargin: 100
                height: 50
                Item {
                    id: descriptionItem
                    anchors.top: parent.top
                    anchors.left: parent.left
                    anchors.bottom: parent.bottom
                    width: 80
                    Label {
                        anchors.left: parent.left
                        text: description
                        font.pixelSize: 18
                        font.bold: true
                        anchors.verticalCenter: parent.verticalCenter
                        font.family: BasicConfig.commFont
                        color: "#ddd"
                    }
                }

                CustomShotCutTextField {
                    id: shotCutTextField
                    height: 40
                    width: 200
                    text: shotcut
                    anchors.verticalCenter: parent.verticalCenter
                    anchors.left: descriptionItem.right
                    anchors.leftMargin: 80
                }
                CustomShotCutTextField {
                    id: globalShotCutTextField
                    height: 40
                    width: 200
                    text: globalShotcut
                    anchors.verticalCenter: parent.verticalCenter
                    anchors.left: shotCutTextField.right
                    anchors.leftMargin: 80
                }
            }
        }
    }

    // 启用全局快捷键
    CustomCheckBox {
        id: useGlobalShartCut
        anchors.left: col1.left
        anchors.top: col1.bottom
        anchors.topMargin: 30
        text: qsTr("启用快捷键(云音乐在后台时也能响应)")
        isSelected: true
    }
    // 使用系统媒体快捷键
    CustomCheckBox {
        id: useSysShortCut
        anchors.left: useGlobalShartCut.left
        anchors.top: useGlobalShartCut.bottom
        anchors.topMargin: 30
        text: qsTr("使用系统媒体快捷键(播放/暂停、上一首、下一首)")
        isSelected: true
    }

    Rectangle {
        height: 40
        width: 120
        radius: 20
        opacity: 1
        color: "transparent"
        border.width: 1
        border.color: BasicConfig.fieldBgBordColor
        anchors.verticalCenter: useSysShortCut.verticalCenter
        anchors.left: useSysShortCut.right
        anchors.leftMargin: 40
        Label {
            color: "#fff"
            font.bold: true
            text: qsTr("默认恢复")
            font.pixelSize: 18
            font.family: BasicConfig.commFont
            anchors.centerIn: parent
        }
        MouseArea {
            anchors.fill: parent
            hoverEnabled: true
            onEntered: {
                cursorShape = Qt.ForbiddenCursor
                parent.opacity = 0.8
            }
            onExited: {
                cursorShape = Qt.ArrowCursor
                parent.opacity = 1
            }
            onClicked: {
                shotCutModel.clear()
                shotCutModel.append({ description: "播放/暂停", shotcut: "Ctrl + P", globalShotcut: "Ctrl + Alt + P" })
                shotCutModel.append( { description: "上一首", shotcut: "Ctrl + Left", globalShotcut: "Ctrl + Alt + Left" })
                shotCutModel.append( { description: "下一首", shotcut: "Ctrl + Right", globalShotcut: "Ctrl + Alt + Right" })
                shotCutModel.append( { description: "音量加", shotcut: "Ctrl + Up", globalShotcut: "Ctrl + Alt + Up" })
                shotCutModel.append( { description: "音量减", shotcut: "Ctrl + Down", globalShotcut: "Ctrl + Alt + Down" })
                shotCutModel.append( { description: "mini/完整模式", shotcut: "Ctrl + M", globalShotcut: "Ctrl + Alt + M" })
                shotCutModel.append( { description: "喜欢歌曲", shotcut: "Ctrl + L", globalShotcut: "Ctrl + Alt + L" })
                shotCutModel.append( { description: "打开/关闭歌词", shotcut: "Ctrl + D", globalShotcut: "Ctrl + Alt + D" })
            }
        }
    }

    CustomPliteLine { }
}

